package cn.tedu.weibo.controller;

import cn.tedu.weibo.common.response.JsonResult;
import cn.tedu.weibo.common.response.StatusCode;
import cn.tedu.weibo.mapper.UserMapper;
import cn.tedu.weibo.pojo.dto.UserLoginDTO;
import cn.tedu.weibo.pojo.dto.UserRegDTO;
import cn.tedu.weibo.pojo.entity.User;
import cn.tedu.weibo.pojo.vo.UserVO;
import cn.tedu.weibo.service.IUserService;
import com.fasterxml.jackson.core.JsonGenerationException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/v1/users/")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("reg")
    public JsonResult reg(@RequestBody UserRegDTO userRegDTO){
        userService.reg(userRegDTO);
        return JsonResult.ok();
    }

    @PostMapping("login")
    public JsonResult login(@RequestBody UserLoginDTO userLoginDTO){ ;
        UserVO userVO = userService.login(userLoginDTO);
        return JsonResult.ok(userVO);
    }
}
